<div style="display:flex;height: auto;flex-direction: column;border-top: 1px solid #e6e6e6; border-bottom: 1px solid #e6e6e6; border-radius: 5px; padding: 10px;">
    <div style="display: flex;align-items: center;">
        <div>
            <Avatar Url="@user.Avatar" Size="Size.ExtraSmall"></Avatar>
        </div>
        <div style="margin-left: 10px;display:flex;align-items: center;">
            <text style="font-size: 15px;color: rgba(81,78,76,0.95)">@user.NickName</text>
        </div>
        <div style="margin-left: 10px;display:flex;align-items: center;">
            <text style="font-size: 13px;color: rgba(81,78,76,0.95)">@Comment.CreateTime</text>
        </div>
        <div style="margin-left: auto;">
            @if (Comment.UserID == UserID)
            {
                <Button IsOutline="true" Color="Color.Danger" style="margin-right: 20px;width: 60px;height: 30px;font-size: 13px" @onclick="DeleteComment" >删除</Button>
            }
        </div>
    </div>
    <div>
        <text>@Comment.Content</text>
    </div>
</div>

@code {
    [Parameter]
    public Comment Comment { get; set; }
    [Parameter]
    public int UserID{get; set; }
    [Parameter] 
    public EventCallback<Comment> OnCommentDeleted { get; set; }
    
    private User user=new User();
    
    protected override void OnInitialized()
    {
        user = User.Where(u=>u.Id==Comment.UserID).First();
    }

    private void DeleteComment()
    {
       //删除评论
       Comment.Delete();
       OnCommentDeleted.InvokeAsync(Comment);
       StateHasChanged();
    }
}

